# -*- coding: utf-8 -*-
# coding=utf-8
import sys
import os
# 获取父目录的绝对路径
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
# 将父目录添加到sys.path
sys.path.append(parent_dir)
from modules.measure_type_recognition import MeasureTypeRecognition

if __name__ == '__main__':
    print(os.getcwd())
    query = '东南地区上个月的MQL个数是多少?'
    sel = [{
        "id": "AUGMENTED_DATASET_LEVEL.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_DIMENSION_FIELD.0c2bf3603bcd7cd295e19909c11b78fe-LEVEL-1659584084158",
        "name": "销售区域", "type": "STRING", "timeLevel": "", "member_amout": ""},
        {
            "id": "AUGMENTED_DATASET_LEVEL.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_DIMENSION_FIELD.affebb66d15867660b4dcd4712c9a7d9-LEVEL-1667896197688",
            "name": "月", "type": "STRING", "timeLevel": "month", "member_amout": ""},
        {
            "id": "AUGMENTED_DATASET_MEASURE.I8a8ae5ca0178549554951b9501785cefe3f00058.MT_METRICS.I8aaa80fb01804bb34bb3a22501805f86f82b02c9",
            "name": "MQL个数", "type": "DOUBLE", "timeLevel": "", "member_amout": ""}]
    measure_type_reg = MeasureTypeRecognition('../data/data_dict.json')
    # 其中question为自然语言查询，sel、having和measure是已经构造好的类SQL字段
    res = measure_type_reg.measure_type(sel)
    print(res)
